package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	"we_go/models"
)

type MainController struct {
	beego.Controller
}

func (this *MainController) Get() {

	//1.对数据的增删改查首先有一个ORM对象
	o := orm.NewOrm()
	user := models.User{}
	//2.操作一个结构体
	user.Name = "1qwewqeqweq11"
	user.Pwd = "22qweqwewq2"
	//3.对结构体对象赋值
	//4.插入
	_, err := o.Insert(&user)
	if err != nil {
		beego.Info("插入失败")
		return
	}

	this.Data["Website"] = "beego.me"
	this.Data["Email"] = "astaxie@gmail.com"
	this.TplName = "index.tpl"
}
